<template>
	<view class="container">
		<view class="flex justify-center padding text-center">
			<view>
				<image v-if="setting.userInfo.avatar" class="image_107 round bg-gray" :src="setting.userInfo.avatar"></image>
				<image v-else class="image_107 round bg-gray" src="../../static/logo.png"></image>
				<view class="text-center">头像</view>
			</view>
		</view>
		<view class="margin-bottom-xs">
			<cu-list-cell :list="menuList" :menuArrow="true" @action="handleRoute"></cu-list-cell>
		</view>
		
		<view class="padding flex flex-direction"><button class="cu-btn  line-grey lg"
				@click="handleLogoOut">退出登录</button></view>
	</view>
</template>

<script setup lang="ts">
	import cuListCell from '@/components/cu-list-cell.vue';
	import {
		ref
	} from 'vue';
	import {
		useSettingStore
	} from '@/stores/index';
	import {
		logout
	} from '@/common/api/login';
	const setting = useSettingStore();
	const menuList = [
		{
			cuIcon: 'noticefill',
			color: 'olive',
			badge: 22,
			name: '昵称',
			desc: setting.userInfo.nickname,
			path: ''
		},
		{
			cuIcon: 'upstagefill',
			color: 'cyan',
			badge: 0,
			name: '电话',
			desc: setting.userInfo.phone,
			path: ''
		},
		// {
		// 	cuIcon: 'questionfill',
		// 	color: 'mauve',
		// 	badge: 0,
		// 	name: '绑定车辆',
		// 	desc: '川A12355',
		// 	path: ''
		// },
		// {
		// 	cuIcon: 'questionfill',
		// 	color: 'mauve',
		// 	badge: 0,
		// 	name: '切换身份',
		// 	desc: '司机',
		// 	path: '/pages/user/identity'
		// },
		{
			cuIcon: 'questionfill',
			color: 'mauve',
			badge: 0,
			name: '证件',
			desc: setting.userInfo.auth == 2 ? '已上传' : '未上传',
			path: setting.userType == 4 ? '/pages/user/certificate' : '/pages/manage/facilitator/create'
		}
	];
	/**
	 * 点击事件
	 */
	const handleLogoOut = () => {
		setting.logout();
		logout();
		uni.redirectTo({
			url: '/views/login/phonelogin'
		});
	};
	/**
	 * 点击事件
	 */
	const handleRoute = (e: any) => {
		uni.navigateTo({
			url: e.currentTarget.dataset.value.path
		});
	};
</script>

<style></style>
